package com.uchiha.nova.core.tool.util;


import com.uchiha.nova.core.tool.support.DictBizVO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author 周林静
 * @Date 2023-01-16,0016 16:10
 * @Version 1.0
 */
public class CascaderUtil {
    public static List<DictBizVO> getChildren(DictBizVO root, List<DictBizVO> all){
        List<DictBizVO> children = all.stream().filter(dictBizVO ->
                dictBizVO.getParentId().toString().equals(root.getValue())
        ).map(item -> {
            //1、找到子菜单
            item.setChildren(getChildren(item, all));
            return item;
        }).collect(Collectors.toList());

        return children;
    }
}
